﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using BCCommon;
using BCDto.OA.Notification.NotificationTransferRecord;
using BCService.OA.Notification.NotificationTransferRecord;
using BCService.Utils;
using BlackCoffeeRESTful.Configs;

namespace BlackCoffeeRESTful.Controllers.Management.OA.Notification.NotificationTransferRecord
{
    /// <summary>
    /// OA系统通知记录移交记录
    /// </summary>
    [ApiExplorerSettings(GroupName = "OAAdmin")]
    [Route("api/v1/sim/[controller]")]
    public class NotificationTransferRecordController : ManagementBaseController
    {
        private readonly INotificationTransferRecordService notificationTransferRecordService;

        public NotificationTransferRecordController(INotificationTransferRecordService notificationTransferRecordService)
        {
            this.notificationTransferRecordService = notificationTransferRecordService;
        }

        #region 添加OA系统通知记录移交记录
        /// <summary>
        ///  添加OA系统通知记录移交记录
        /// </summary>
        /// <param name="requestDto">OA系统通知记录移交记录信息</param>
        /// <response code="201">添加OA系统通知记录移交记录成功</response>
        /// <returns></returns>
        [HttpPost]
        [Log("添加OA系统通知记录移交记录")]
        [ProducesResponseType(typeof(NotificationTransferRecordDto), 201)]
        public IActionResult Post(
            [FromBody]NotificationTransferRecordRequestDto requestDto)
        {
            var result = this.notificationTransferRecordService.Add(requestDto);
            return this.Created(string.Format("api/v1/sim/NotificationTransferRecord/{0}", result.NotificationTransferRecordId), result);
        }
        #endregion

        #region 修改OA系统通知记录移交记录
        /// <summary>
        ///  修改OA系统通知记录移交记录
        /// </summary>
        /// <param name="notificationTransferRecordId">OA系统通知记录移交记录Id</param>
        /// <param name="requestDto">OA系统通知记录移交记录信息</param>
        /// <response code="200">修改OA系统通知记录移交记录成功</response>
        /// <returns></returns>
        [HttpPut("{notification_transfer_record_id}")]
        [Log("修改OA系统通知记录移交记录")]
        [ProducesResponseType(typeof(NotificationTransferRecordDto), 200)]
        public IActionResult Post([FromRoute(Name = "notification_transfer_record_id")]long notificationTransferRecordId, [FromBody]NotificationTransferRecordRequestDto requestDto)
        {
            NotificationTransferRecordPutDto putDto = requestDto.As<NotificationTransferRecordPutDto>();
            putDto.NotificationTransferRecordId = notificationTransferRecordId;
            return this.Ok(this.notificationTransferRecordService.Update(putDto));
        }
        #endregion

        #region 删除OA系统通知记录移交记录
        /// <summary>
        ///  删除OA系统通知记录移交记录
        /// </summary>
        /// <param name="notificationTransferRecordId">OA系统通知记录移交记录Id</param>
        /// <response code="204">删除OA系统通知记录移交记录成功</response>
        /// <returns></returns>
        [HttpDelete("{notification_transfer_record_id}")]
        [Log("删除OA系统通知记录移交记录")]
        public IActionResult Delete([FromRoute(Name = "notification_transfer_record_id")]long notificationTransferRecordId)
        {
            this.notificationTransferRecordService.Delete(notificationTransferRecordId);
            return this.NoContent();
        }
        #endregion

        #region 获取OA系统通知记录移交记录
        /// <summary>
        ///  获取OA系统通知记录移交记录
        /// </summary>
        /// <param name="notificationTransferRecordId">OA系统通知记录移交记录Id</param>
        /// <response code="200">获取OA系统通知记录移交记录</response>
        /// <returns></returns>
        [HttpGet("{notification_transfer_record_id}")]
        [ProducesResponseType(typeof(NotificationTransferRecordDto), 200)]
        public IActionResult Get([FromRoute(Name = "notification_transfer_record_id")]long notificationTransferRecordId)
        {
            return this.Ok(this.notificationTransferRecordService.GetEntity(notificationTransferRecordId));
        }
        #endregion

        #region 获取OA系统通知记录移交记录列表
        /// <summary>
        ///  获取OA系统通知记录移交记录列表
        /// </summary>
        /// <response code="200">获取OA系统通知记录移交记录列表</response>
        /// <returns></returns>
        [HttpGet]
        [ProducesResponseType(typeof(NotificationTransferRecordDto), 200)]
        public IActionResult Get()
        {
            return this.Ok(this.notificationTransferRecordService.GetList());
        }
        #endregion

        #region 获取OA系统通知记录移交记录（分页）
        /// <summary>
        ///  获取OA系统通知记录移交记录（分页）
        /// </summary>
        /// <param name="pageIndex">以 1 起始的页码 (默认 1)。</param>
        /// <param name="pageSize">每页要显示的行数 (默认 10)。</param>
        /// <response code="200">获取OA系统通知记录移交记录（分页）</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<NotificationTransferRecordDto>), 200)]
        public IActionResult Query(int pageIndex = 1,
            int pageSize = 10)
        {
            return this.Ok(this.notificationTransferRecordService.Query(pageIndex, pageSize));
        }
        #endregion

    }
}
